<?php

function tf_get_used_colors() {
  global $thfr_css;

  $color_property_array = array(
    'color',
    'background-color',
    'border-color',
    'border-top-color',
    'border-right-color',
    'border-bottom-color',
    'border-left-color'
  );

  $used_colors = array();

  foreach ($thfr_css['internal_css'] as $option => $selector) {
    if (is_array($selector)) {
      foreach ($selector as $property => $value) {
        if (in_array($property, $color_property_array)) {
          $used_colors[] = str_replace('#', '', $value);
        }
      }
    }
  }

  $result = array_unique($used_colors);
  sort($result);

  header('Content-Type: application/json');
  echo json_encode($result);
  /*
  die();
  */
}

?>
